www.gusucode.com > 24Beta 虚拟主机版 1.0.0 Beta源码程序 > 24Beta 虚拟主机版 1.0.0 Beta源码程序/24Beta-1.0.0-vhost/protected/models/SpamWords.php
<?php class SpamWords extends CActiveRecord { const YES = 1; const NO = 0; /** * The followings are the available columns in table 'SpamWords': * @var integer $id * @var string $subject * @var string $replace * @var integer $isvalid */ /** * Returns the static model of the specified AR class. * @return CActiveRecord the static model class */ public static function model($className=__CLASS__) { return parent::model($className); } /** * @return string the associated database table name */ public function tableName() { return 'SpamWords'; } /** * @return array validation rules for model attributes. */ public function rules() { return array( array('subject','length','max'=>50), array('replace','length','max'=>50), array('isvalid', 'numerical', 'integerOnly'=>true), ); } /** * @return array relational rules. */ public function relations() { // NOTE: you may need to adjust the relation name and the related // class name for the relations automatically generated below. return array( ); } /** * @return array customized attribute labels (name=>label) */ public function attributeLabels() { return array( 'id' => 'Id', 'subject' => '敏感词语', 'replace' => '替换词语', 'isvalid' => '启用', ); } public function getAllValidWords() { $cacheId = param('cacheIdSpamWords'); param('caching') && $data = app()->cache->get($cacheId); if (!param('caching') || $data == false) { $data = self::model()->findAll('isvalid = ' . self::YES); param('caching') && app()->cache->set($cacheId, $data, param('expireSpamWords')); } return $data; } }